import random
from faker import Faker
from datetime import datetime, timedelta
import json


fake = Faker()
Faker.seed(42)
random.seed(42)
countries_bak = {
    "Vietnam": ("VN", "en"),  # 越南
    "Indonesia": ("ID", "id"),  # 印度尼西亚
    "Philippines": ("PH", "en"),  # 菲律宾
    "Thailand": ("TH", "th"),  # 泰国
    "Malaysia": ("MY", "Malaysia"),  # 马来西亚

    "Japan": ("JP", "ja"),  # 日本
    "South Korea": ("KR", "ko"),  # 韩国

    "Poland": ("PL", "pl"),  # 波兰
    "Romania": ("RO", "ro"),  # 罗马尼亚
    "Czechia": ("CZ", "cs"),  # 捷克
    "Ukraine": ("UA", "uk"),  # 乌克兰

    "United States": ("US", "en"),  # 美国
    "Canada": ("CA", "ca"),  # 加拿大
    "United Kingdom": ("GB", "en"),  # 英国
    "Germany": ("DE", "de"),  # 德国
    "France": ("FR", "fr"),  # 法国
    "Italy": ("IT", "it"),  # 意大利
    "Spain": ("ES", "es"),  # 西班牙
}

# 国家配置（国家名称: 国家编码, 母语）
countries = {

    "Japan": ("JP", "ja"),  # 日本

}

# 生日生成函数（18-35岁之间）
def random_birthday_18_35():
    start_date = datetime.now() - timedelta(days=33*365)
    end_date = datetime.now() - timedelta(days=22*365)
    return fake.date_between(start_date=start_date, end_date=end_date).isoformat()

# 用户生成函数
def generate_user(country_name, country_code, language, gender):
    nickname = fake.first_name_male() if gender == "male" else fake.first_name_female()
    bio = fake.text(max_nb_chars=150)
    return {
        "nickname": nickname,
        "country_code": country_code,
        "language": language,
        "gender": gender,
        "email": fake.first_name()+ str(random.randint(100000, 999999))+"05162@example.com"   ,
        "birthday": random_birthday_18_35(),
        "bio": bio,
        "group": f"{country_name}_{gender}"
    }

# 生成用户：每个国家、每个性别生成10个用户
users = []
for country_name, (code, lang) in countries.items():
    #for gender in ["male", "female"]:
    for gender in [ "female"]:
        for _ in range(218):
            users.append(generate_user(country_name, code, lang, gender))

# 可选：保存为 JSON 文件
with open("D:\pyimg\generated_Japan_female_users.json", "w", encoding="utf-8") as f:
    json.dump(users, f, indent=2)

print("共生成用户数：", len(users))

